< previous page page_971 next page >

Page 971
Answers to Day 11 Exercises
You can complete this project by performing the following steps:
1. Create the database in Visdata. Build the table, add the fields, and enter the data.
2. Start Visual Basic and begin a new project. Insert LIBGRAPH.BAS and FRMGRAPH.FRM into your project.
3. Build the new form by adding the command buttons. Insert the following code behind each button:
Private Sub cmdPie_Click()

    Dim rsFile As Recordset
    Dim dbFile As DATABASE
    Dim cSQL As String
    Dim cField As String
    Dim cTitle As String
    Dim cLegend As String
    Dim cLabel As String
    Dim dbName As String

    cSQL = "Select * from Activity WHERE month =1"
    cField = "Passengers"
    cLegend = ""
    cLabel = "Airline"
    cTitle = "Market Share for January"
    dbName = "c:\abc\ch12\12abcex.mdb"

    Set dbFile = DBEngine.OpenDatabase(dbName)
    Set rsFile = dbFile.OpenRecordset(cSQL, dbOpenSnapshot)

    ShowGraph gphPie3D, rsFile, cField, cTitle,
   _cFldLegend:=cLegend, cFldLabel:=cLabel

End Sub

Private Sub cmdLine_Click()

    Dim rsFile As Recordset
    Dim dbFile As DATABASE
    Dim cSQL As String
    Dim cField As String
    Dim cTitle As String
    Dim cLegend As String
    Dim cLabel As String
    Dim dbName As String

    cSQL = "Select Month, Sum(Passengers) as TotPassengers from
    _Activity Group by Month;"
    cField = "TotPassengers"
    cLegend = ""
    cLabel = "Month"
    cTitle = "Total Activity"
    dbName = "c:\abc\ch12\12abcex.mdb"

 
< previous page page_971 next page >

If you like this book, buy it!